package com.ruoyi.web.controller.project.standard;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.project.standard.StandardTeacher;
import com.ruoyi.system.service.project.IStandardTeacherService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 标准教师Controller
 * 
 * @author ruoyi
 * @date 2025-08-28
 */
@RestController
@RequestMapping("/project/standard/teacher")
public class StandardTeacherController extends BaseController
{
    @Autowired
    private IStandardTeacherService standardTeacherService;

    /**
     * 查询标准教师列表
     */
    @PreAuthorize("@ss.hasPermi('system:teacher:list')")
    @GetMapping("/list")
    public TableDataInfo list(StandardTeacher standardTeacher)
    {
        startPage();
        List<StandardTeacher> list = standardTeacherService.selectStandardTeacherList(standardTeacher);
        return getDataTable(list);
    }

    /**
     * 导出标准教师列表
     */
    @PreAuthorize("@ss.hasPermi('system:teacher:export')")
    @Log(title = "标准教师", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, StandardTeacher standardTeacher)
    {
        List<StandardTeacher> list = standardTeacherService.selectStandardTeacherList(standardTeacher);
        ExcelUtil<StandardTeacher> util = new ExcelUtil<StandardTeacher>(StandardTeacher.class);
        util.exportExcel(response, list, "标准教师数据");
    }

    /**
     * 获取标准教师详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:teacher:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(standardTeacherService.selectStandardTeacherById(id));
    }

    /**
     * 新增标准教师
     */
    @PreAuthorize("@ss.hasPermi('system:teacher:add')")
    @Log(title = "标准教师", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StandardTeacher standardTeacher)
    {
        return toAjax(standardTeacherService.insertStandardTeacher(standardTeacher));
    }

    /**
     * 修改标准教师
     */
    @PreAuthorize("@ss.hasPermi('system:teacher:edit')")
    @Log(title = "标准教师", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StandardTeacher standardTeacher)
    {
        return toAjax(standardTeacherService.updateStandardTeacher(standardTeacher));
    }

    /**
     * 删除标准教师
     */
    @PreAuthorize("@ss.hasPermi('system:teacher:remove')")
    @Log(title = "标准教师", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(standardTeacherService.deleteStandardTeacherByIds(ids));
    }
}
